package com.yuyou.fn.tms.service.impl;

import com.google.common.collect.Lists;
import com.yuyou.fn.common.util.Utils;
import com.yuyou.fn.educational.entity.*;
import com.yuyou.fn.educational.service.*;
import com.yuyou.fn.settlement.entity.MainAccount;
import com.yuyou.fn.settlement.service.IMainAccountService;
import com.yuyou.fn.tms.service.IQueryDataService;
import com.yuyou.fn.tms.vo.*;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;

@Service
public class QueryDataServiceImpl implements IQueryDataService {
    @Resource
    private ICourseClassService courseClassService;

    @Resource
    private IMainAccountService mainAccountService;

    @Resource
    private ITeacherService teacherService;

    @Override
    public List<ClassQuota> findClassQuotaList(QueryClassParam queryClassParam) {
        List<CourseClass> courseClassList=courseClassService.findByIds(Utils.toLongIds(queryClassParam.getClaIds()),"classId","quota","lockAmount","regAmount");
        List<ClassQuota> list = Lists.transform(courseClassList, item -> {
            return new ClassQuota(item);
        });
        return list;
    }

    @Override
    public List<ClassFee> findClassFeeList(QueryClassParam queryClassParam) {
        List<CourseClass> courseClassList=courseClassService.findByIds(Utils.toLongIds(queryClassParam.getClaIds()),"classId","quota","lockAmount","regAmount","studyingFee","materialFee");
        List<ClassFee> list = Lists.transform(courseClassList, item -> {
            return new ClassFee(item);
        });
        return list;
    }

    @Override
    public StudentAccount findStudentAccount(QueryAccountParam queryAccountParam) {
        MainAccount mainAccount=mainAccountService.findById(queryAccountParam.getStuId());
        StudentAccount studentAccount=new StudentAccount(mainAccount);
        return studentAccount;
    }

    @Override
    public List<TmsTeacherDetail> findTeacherDetail(QueryTeacherParam queryTeacherParam) {
        List<Teacher> teacherList=teacherService.findByIds(Utils.toLongIds(queryTeacherParam.getTeaIds()));
        List<TmsTeacherDetail> list = Lists.transform(teacherList, item -> {
            return new TmsTeacherDetail(item);
        });
        return list;
    }
}
